home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-GM / MPW / Examples / CExamples / Sample.r < prev    next >
Encoding:
Text File  |  1998-12-03  |  6.2 KB  |  288 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.r    -    Rez Source
  10. #
  11. #    Copyright © Apple Computer, Inc. 1989-1990, 1998
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89    MPW 3.1
  18. #                1.03                02/90    MPW 3.2
  19. #                1.04                06/98    Universal Interfaces 3.1
  20. #
  21. #    Components:
  22. #                Sample.c            Feb.  1, 1990
  23. #                Sample.r            Feb.  1, 1990
  24. #                Sample.h            Feb.  1, 1990
  25. #                Sample.make            Feb.  1, 1990
  26. #
  27. #    Sample is an example application that demonstrates how to
  28. #    initialize the commonly used toolbox managers, operate 
  29. #    successfully under MultiFinder, handle desk accessories, 
  30. #    and create, grow, and zoom windows.
  31. #
  32. #    It does not by any means demonstrate all the techniques 
  33. #    you need for a large application. In particular, Sample 
  34. #    does not cover exception handling, multiple windows/documents, 
  35. #    sophisticated memory management, printing, or undo. All of 
  36. #    these are vital parts of a normal full-sized application.
  37. #
  38. #    This application is an example of the form of a Macintosh 
  39. #    application; it is NOT a template. It is NOT intended to be 
  40. #    used as a foundation for the next world-class, best-selling, 
  41. #    600K application. A stick figure drawing of the human body may 
  42. #    be a good example of the form for a painting, but that does not 
  43. #    mean it should be used as the basis for the next Mona Lisa.
  44. #
  45. #    We recommend that you review this program or TESample before 
  46. #    beginning a new application.
  47. ------------------------------------------------------------------------------*/
  48.  
  49.  
  50. #include "SysTypes.r"
  51. #include "Types.r"
  52.  
  53. #include "Sample.h"
  54.  
  55. resource 'vers' (1) {
  56.     0x02, 0x00, release, 0x00,
  57.     verUS,
  58.     "1.03",
  59.     "1.03, Copyright \251 Apple Computer, Inc. 1989-1990"
  60. };
  61.  
  62.  
  63. /* this is a definition for a resource which contains only a rectangle */
  64.  
  65. type 'RECT' {
  66.     rect;
  67. };
  68.  
  69.  
  70. /* we use an MBAR resource to conveniently load all the menus */
  71.  
  72. resource 'MBAR' (rMenuBar, preload) {
  73.     { mApple, mFile, mEdit, mLight };    /* four menus */
  74. };
  75.  
  76.  
  77. resource 'MENU' (mApple, preload) {
  78.     mApple, textMenuProc,
  79.     AllItems & ~MenuItem2,    /* Disable dashed line, enable About and DAs */
  80.     enabled, apple,
  81.     {
  82.         "About Sample…",
  83.             noicon, nokey, nomark, plain;
  84.         "-",
  85.             noicon, nokey, nomark, plain
  86.     }
  87. };
  88.  
  89. resource 'MENU' (mFile, preload) {
  90.     mFile, textMenuProc,
  91.     MenuItem12,                /* enable Quit only, program enables others */
  92.     enabled, "File",
  93.     {
  94.         "New",
  95.             noicon, "N", nomark, plain;
  96.         "Open",
  97.             noicon, "O", nomark, plain;
  98.         "-",
  99.             noicon, nokey, nomark, plain;
  100.         "Close",
  101.             noicon, "W", nomark, plain;
  102.         "Save",
  103.             noicon, "S", nomark, plain;
  104.         "Save As…",
  105.             noicon, nokey, nomark, plain;
  106.         "Revert",
  107.             noicon, nokey, nomark, plain;
  108.         "-",
  109.             noicon, nokey, nomark, plain;
  110.         "Page Setup…",
  111.             noicon, nokey, nomark, plain;
  112.         "Print…",
  113.             noicon, nokey, nomark, plain;
  114.         "-",
  115.             noicon, nokey, nomark, plain;
  116.         "Quit",
  117.             noicon, "Q", nomark, plain
  118.     }
  119. };
  120.  
  121. resource 'MENU' (mEdit, preload) {
  122.     mEdit, textMenuProc,
  123.     NoItems,                /* disable everything, program does the enabling */
  124.     enabled, "Edit",
  125.      {
  126.         "Undo",
  127.             noicon, "Z", nomark, plain;
  128.         "-",
  129.             noicon, nokey, nomark, plain;
  130.         "Cut",
  131.             noicon, "X", nomark, plain;
  132.         "Copy",
  133.             noicon, "C", nomark, plain;
  134.         "Paste",
  135.             noicon, "V", nomark, plain;
  136.         "Clear",
  137.             noicon, nokey, nomark, plain
  138.     }
  139. };
  140.  
  141. resource 'MENU' (mLight, preload) {
  142.     mLight, textMenuProc,
  143.     NoItems,                /* disable everything, program does the enabling */
  144.     enabled, "Traffic",
  145.      {
  146.         "Red Light",
  147.             noicon, nokey, nomark, plain;
  148.         "Green Light",
  149.             noicon, nokey, nomark, plain
  150.     }
  151. };
  152.  
  153.  
  154. /* this ALRT and DITL are used as an About screen */
  155.  
  156. resource 'ALRT' (rAboutAlert, purgeable) {
  157.     {40, 20, 160, 297},
  158.     rAboutAlert,
  159.     { /* array: 4 elements */
  160.         /* [1] */
  161.         OK, visible, silent,
  162.         /* [2] */
  163.         OK, visible, silent,
  164.         /* [3] */
  165.         OK, visible, silent,
  166.         /* [4] */
  167.         OK, visible, silent
  168.     },
  169.     centerMainScreen
  170. };
  171.  
  172. resource 'DITL' (rAboutAlert, purgeable) {
  173.     { /* array DITLarray: 5 elements */
  174.         /* [1] */
  175.         {88, 185, 108, 265},
  176.         Button {
  177.             enabled,
  178.             "OK"
  179.         },
  180.         /* [2] */
  181.         {8, 8, 24, 214},
  182.         StaticText {
  183.             disabled,
  184.             "Simple Sample (Traffic Light)"
  185.         },
  186.         /* [3] */
  187.         {32, 8, 48, 296},
  188.         StaticText {
  189.             disabled,
  190.             "Copyright © Apple Computer 1989-1990"
  191.         },
  192.         /* [4] */
  193.         {56, 8, 72, 136},
  194.         StaticText {
  195.             disabled,
  196.             "Brought to you by:"
  197.         },
  198.         /* [5] */
  199.         {80, 24, 112, 167},
  200.         StaticText {
  201.             disabled,
  202.             "Macintosh Developer  Technical Support"
  203.         }
  204.     }
  205. };
  206.  
  207.  
  208. /* this ALRT and DITL are used as an error screen */
  209.  
  210. resource 'ALRT' (rUserAlert, purgeable) {
  211.     {40, 20, 120, 260},
  212.     rUserAlert,
  213.     { /* array: 4 elements */
  214.         /* [1] */
  215.         OK, visible, silent,
  216.         /* [2] */
  217.         OK, visible, silent,
  218.         /* [3] */
  219.         OK, visible, silent,
  220.         /* [4] */
  221.         OK, visible, silent
  222.     },
  223.     centerMainScreen
  224. };
  225.  
  226.  
  227. resource 'DITL' (rUserAlert, purgeable) {
  228.     { /* array DITLarray: 3 elements */
  229.         /* [1] */
  230.         {50, 150, 70, 230},
  231.         Button {
  232.             enabled,
  233.             "OK"
  234.         },
  235.         /* [2] */
  236.         {10, 60, 30, 230},
  237.         StaticText {
  238.             disabled,
  239.             "Sample - Error occurred!"
  240.         },
  241.         /* [3] */
  242.         {8, 8, 40, 40},
  243.         Icon {
  244.             disabled,
  245.             2
  246.         }
  247.     }
  248. };
  249.  
  250.  
  251. resource 'WIND' (rWindow, preload, purgeable) {
  252.     {60, 40, 290, 160},
  253.     noGrowDocProc, visible, noGoAway, 0x0, "Traffic", noAutoCenter
  254. };
  255.  
  256. resource 'RECT' (rStopRect, preload, purgeable) {
  257.     {10, 10, 110, 110}
  258. };
  259.  
  260. resource 'RECT' (rGoRect, preload, purgeable) {
  261.     {120, 10, 220, 110}
  262. };
  263.  
  264.  
  265. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  266.  
  267. resource 'SIZE' (-1) {
  268.     dontSaveScreen,
  269.     acceptSuspendResumeEvents,
  270.     enableOptionSwitch,
  271.     canBackground,                /* we can background; we don't currently, but our sleep value */
  272.                                 /* guarantees we don't hog the Mac while we are in the background */
  273.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  274.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  275.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  276.     ignoreChildDiedEvents,        /* essentially, I'm not a debugger (sub-launching) */
  277.     not32BitCompatible,            /* this app should not be run in 32-bit address space */
  278.     reserved,
  279.     reserved,
  280.     reserved,
  281.     reserved,
  282.     reserved,
  283.     reserved,
  284.     reserved,
  285.     kPrefSize * 1024,
  286.     kMinSize * 1024    
  287. };
  288.